home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
softwareupdate
/
system
/
amigados
/
amigadoslibrary
/
flush.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-10
|
1KB
|
70 lines
/* Flush.c V1.2 93-03-03 */
/* ROM library: "dos.library/Flush", (V36+) */
/* Copyright 1993, Anders Bjerin, Amiga C Club */
#include <dos/dos.h>
#include <clib/dos_protos.h>
#include <stdio.h>
#include <stdlib.h>
#define BUFFER_SIZE 14
UBYTE *version = "$VER: Flush 1.2";
int main( int argc, char *argv[] );
int main( int argc, char *argv[] )
{
int loop;
BPTR my_file;
int actual;
BOOL ok;
UBYTE my_read_buffer[ BUFFER_SIZE ];
UBYTE my_write_buffer[ BUFFER_SIZE ] =
{
'!', 'b', 'u', 'l', 'C', ' ', 'C', ' ', 'a', 'g', 'i', 'm', 'A', '\n'
};
/* Open a new file: */
my_file = Open( "RAM:ReadThis.dat", MODE_NEWFILE );
if( !my_file )
exit( 20 );
/* Use a buffered output routine: */
for( loop = BUFFER_SIZE - 1; loop >= 0; loop-- )
{
actual = FPutC( my_file, my_write_buffer[ loop ] );
if( actual == -1 )
{
Close( my_file );
exit( 21 );
}
}
/* Flush the temporary dos buffer: */
ok = Flush( my_file );
/* Any problems? */
if( ok )
printf( "Buffer was flushed successfully!\n" );
else
printf( "Problems while flushing the buffer!\n" );
/* Move to the begining of the file */
Seek( my_file, 0, OFFSET_BEGINNING );
/* Use a un-buffered input routine: */
actual = Read( my_file, my_read_buffer, BUFFER_SIZE );
if( actual != BUFFER_SIZE )
{
Close( my_file );
exit( 23 );
}
printf( "%s\n", my_read_buffer );
Close( my_file );
exit( 0 );
}